<md-dialog aria-label="{{ 'ADMINCONSOLE.DIALOG.TRUSTED_APP.ARIA' | translate }}"
           style="max-width: 800px;">
    <form name="vm.trustedDomainForm" ng-submit="vm.submit()" novalidate style="overflow: initial;" layout-padding>
        <md-dialog-content layout="column" layout-padding>
            <div>
                <h2 ng-show="vm.isNew">{{ 'ADMINCONSOLE.DIALOG.TRUSTED_DOMAIN.TITLE_NEW' | translate }}</h2>
                <h2 ng-show="!vm.isNew">{{ 'ADMINCONSOLE.DIALOG.TRUSTED_APP.TITLE_EDIT' | translate }}: {{vm.title}}</h2>
            </div>

            <div layout="column">
                <md-input-container md-theme="eBlockerThemeInput" style="width: 100%;">
                    <label>{{ 'ADMINCONSOLE.DIALOG.TRUSTED_DOMAIN.LABEL_NAME' | translate }}</label>
                    <input name="name" ng-model="vm.module.label" type="text" md-maxlength="50" required/>
                    <div ng-messages="vm.trustedDomainForm.name.$error" ng-if="vm.trustedDomainForm.$submitted || vm.trustedDomainForm.name.$touched">
                        <div ng-message="required">{{ 'ADMINCONSOLE.DIALOG.TRUSTED_DOMAIN.ERROR.NAME_REQUIRED' | translate }}</div>
                        <div ng-message="md-maxlength">{{ 'ADMINCONSOLE.DIALOG.TRUSTED_DOMAIN.ERROR.NAME_TOO_LONG' | translate }}</div>
                    </div>
                </md-input-container>
                <md-input-container md-theme="eBlockerThemeInput" style="width: 100%;">
                    <label>{{ 'ADMINCONSOLE.DIALOG.TRUSTED_DOMAIN.LABEL_DOMAIN' | translate }}</label>
                    <textarea name="url" type="text"  eb-url-domains ng-model="vm.module.domainsText" ng-change="vm.onChangeDomain()" required></textarea>
                    <div ng-messages="vm.trustedDomainForm.url.$error" ng-if="vm.trustedDomainForm.$submitted || vm.trustedDomainForm.url.$touched">
                        <div ng-message="required">{{ 'ADMINCONSOLE.DIALOG.TRUSTED_DOMAIN.ERROR.DOMAINS_REQUIRED' | translate }}</div>
                        <div ng-message="md-maxlength">{{ 'ADMINCONSOLE.DIALOG.TRUSTED_DOMAIN.ERROR.DOMAINS_TOO_LONG' | translate }}</div>
                        <div ng-message="urlDomains">{{ 'ADMINCONSOLE.DIALOG.TRUSTED_DOMAIN.ERROR.DOMAINS_INVALID' | translate }}</div>
                        <div ng-message="validDomain">{{ 'ADMINCONSOLE.DIALOG.TRUSTED_DOMAIN.ERROR.DOMAINS_INVALID' | translate }}</div>
                    </div>
                </md-input-container>
            </div>
        </md-dialog-content>

        <md-dialog-actions layout="row"
                           layout-align="end center"
                           layout-xs="column"
                           layout-align-xs="center center"
                           style="padding-right: 16px;">
            <md-button type="button" ng-click="vm.cancel()" class="md-raised md-secondary">{{ 'ADMINCONSOLE.DIALOG.TRUSTED_APP.ACTION.CANCEL' | translate }}</md-button>
            <md-button type="submit" class="md-raised md-primary md-accent">{{ 'ADMINCONSOLE.DIALOG.TRUSTED_APP.ACTION.OK' | translate }}</md-button>
        </md-dialog-actions>
    </form>
</md-dialog>
